#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
	int n,x;
	scanf("%d %d", &n, &x);
	int count = 0;
	int i = 0;
	for (i = 1; i <= n; i++)
	{
		int tmp = i;
		while (tmp)
		{
			if (tmp % 10 == x)
			{
				count++;
			}
			tmp /= 10;
		}	
	}
	printf("%d", count);
	return 0;
}




